package com.github.catvod.spider.merge;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import javax.annotation.Nullable;

/* loaded from: classes.dex */
abstract class v6 extends ms {
    int V0;
    final ArrayList<ms> h;

    static final class Tw extends v6 {
        Tw(Collection<ms> collection) {
            super(collection);
        }

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            for (int i = this.V0 - 1; i >= 0; i--) {
                if (!this.h.get(i).h(lm, lm2)) {
                    return false;
                }
            }
            return true;
        }

        public String toString() {
            return ZG.Qy(this.h, "");
        }

        Tw(ms... msVarArr) {
            this(Arrays.asList(msVarArr));
        }
    }

    v6() {
        this.V0 = 0;
        this.h = new ArrayList<>();
    }

    void V0(ms msVar) {
        this.h.set(this.V0 - 1, msVar);
    }

    @Nullable
    ms j() {
        int i = this.V0;
        if (i > 0) {
            return this.h.get(i - 1);
        }
        return null;
    }

    void q() {
        this.V0 = this.h.size();
    }

    v6(Collection<ms> collection) {
        this();
        this.h.addAll(collection);
        q();
    }

    static final class yh extends v6 {
        yh(Collection<ms> collection) {
            if (this.V0 > 1) {
                this.h.add(new Tw(collection));
            } else {
                this.h.addAll(collection);
            }
            q();
        }

        public void I(ms msVar) {
            this.h.add(msVar);
            q();
        }

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            for (int i = 0; i < this.V0; i++) {
                if (this.h.get(i).h(lm, lm2)) {
                    return true;
                }
            }
            return false;
        }

        public String toString() {
            return ZG.Qy(this.h, ", ");
        }

        yh(ms... msVarArr) {
            this(Arrays.asList(msVarArr));
        }

        yh() {
        }
    }
}
